vimfandomcom-20200223-history
Did you know
__NOEDITSECTION__ This is an archive of the Did you know? section on the home page We occasionally replace the DYK section on the home page, and items are copied to here so anyone interested can browse them. To discuss suggestions for new items, please edit the talk page. July 2012 *The Vim FAQ is online. *There are several methods to change the indentation of a block of lines. *A mapping can change the Home key to move to the first character, or the first that is nonblank. *Filtering and redirection can capture output from Vim or external programs. *It's easy to change between backslash and forward slash in a file path. *If you create your own tags file, you can [[VimTip601|jump to the correct line and column]]. *If you work with many files, it's easy to save them all with :wa or :xa. *Simple substitutes or a Perl script can convert text using HTML entities like >. *The command :g/^/exe ".w ".line(".").".txt" saves each line in the buffer to a separate file. *:g// lists all lines containing the last search pattern, and :redir will capture the results. *With set browsedir=buffer the File, Open dialog defaults to the current file's directory. May 2010 *@: will repeat a colon (Ex) command (and @@ will repeat again). *You can use :g/^\s*$/;//-1sort to sort each block of lines in a file. *It's useful to map . .`[ to repeat the last command and put the cursor at start of change. *You can open a web browser with the URL in the current line. *With --remote-send you can close a Vim you left open remotely. *If you're used to Perl regex, you can use Perl compatible regular expressions. *In insert mode, Ctrl-Y inserts the character above. You can make it insert the word above. *A user-defined command can evaluate :Calc sin(pi/2). *It's sometimes better to ''not'' use the slash delimiter for :s/old/new/. *You can drag & drop one or more files into gvim. April 2010 *zz scrolls the current line to the middle of the screen; scrolloff can keep it there. *Vim can do calculations using Python, Perl or bc. *You can wrap long lines while moving the cursor by screen lines. *A tricky search can [[VimTip220|find text that does not match]]. *Pressing % jumps to a matching bracket, and matchit.vim can match much more. *The shortmess and cmdheight options allow you to avoid "Hit Enter to continue" prompts. *An option controls how backspace and other delete keys work in insert mode. *You can display line numbers and change the width of the number column. *It's easy to change text between lowercase and UPPERCASE. *The command history allows you to repeat several commands, possibly after editing them. March 2010 *Vim tutorials has videos illustrating simple and advanced topics. *Use % to jump to the matching bracket, and more. *Use :lcd %:p:h to change directory to the file in the current window. *ga shows the ascii value of the current character. *You can list changes to the current file, even old changes. *Use za to toggle folds open/closed. *The status line can show your fileencoding and bomb. *In a program, you can jump to the beginning or end of a code block. *With two related files in a vertical split, you can scroll both windows together. *It's easy to count the words in a file or block. *You can even make a frequency table counting the occurrences of each word! February 2010 *Vim tutorials has videos illustrating simple and advanced topics. *You can press * to search for the current word. *Ctrl-A can increment numbers. *After typing a couple of characters, you can complete a word with Ctrl-N or Ctrl-P. *Vim's help use prefixes like v_ (visual mode) to show the context. *The :let command can set registers and options as well as variables. *The command :42 jumps to line 42, as does typing 42G. *The shortmess and cmdheight options allow you to avoid "Hit Enter to continue" prompts. *The 'backspace' option controls how backspace and other delete keys work in insert mode. *The 'number' and 'numberwidth' options control the display of line numbers. *It's easy to change text between lowercase and UPPERCASE. January 2010 *Vim tutorials has videos illustrating simple and advanced topics. *We have an explanation for how :g/^/m0 reverses all lines. *In a search pattern, \_s matches a space or tab or newline character. *A script can use a test like &buftype "quickfix" to check if it is operating in the quickfix window. *Typing =i{ reindents the "inner block" (code inside braces). *Using 'smartindent' means that typing # may remove an indent before the #. *The 'winaltkeys' option controls whether Vim handles Alt keys. *If you would prefer Y to be consistent with C, use :nnoremap Y y$. *A plugin should set its "loaded" variable to show its version, for example let g:loaded_dbext = 503. *We have a short FAQ for new users concerning common issues raised at #vim. *You can use :cnoremap to map a key to e(...) which will replace the command line with the (...) expression. Previous years *[[/2009|2009 Did you know]] *[[/2008|2008 Did you know]] Category:VimInformation